﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KulaTools
{
    public class WebConfig
    {
        /// <summary>
        /// Get a the "key" value from the current AppSettings. Throws error only if key missing. Empty string is valid! (WebConfig / AppConfig)
        /// </summary>
        /// <param name="key"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public static string GetValue(string key, string errorMessage)
        {

            if (ConfigurationManager.AppSettings[key] == null)
            {
                throw new Exception(errorMessage);
            }
            else
            {
                return ConfigurationManager.AppSettings[key];
            }


        }
    }
}
